package cn.edu.glut.entity;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import com.fasterxml.jackson.annotation.JsonBackReference;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * 
 * @author Caizhfy
 * @email caizhfy@163.com
 * @createTime 2017年12月6日
 * @description 学生
 *
 */
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true, exclude = {"selections","major"})
@Entity
public class Student extends User {
	private static final long serialVersionUID = 5548746410179163189L;
	private String sclass; // 班级
	private String contact; // 联系方式（电话号码）
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "major_id")
	private Major major; // 所属专业
	@OneToMany(mappedBy="student")
	@JsonBackReference
	private List<Selection> selections;
	
	public Student(String id){
		super();
		this.id = id;
	}
}
